package com.lbn.monitor.app.login;

import android.text.TextUtils;

import com.free.framework.business.NetSubscriber;
import com.lbn.monitor.api.AppHost;
import com.lbn.monitor.api.model.User;
import com.lbn.monitor.base.AppBasePresenter;

import java.util.List;

/**
 * @author 李炳南
 * @date 2017/3/8
 */
public class LoginPresenter extends AppBasePresenter<ILoginView>{



    public void login(String userName,String password){

        if(TextUtils.isEmpty(userName)||TextUtils.isEmpty(password)){
            getView().showToast("用户名、密码不能为空");
            return;
        }



        subscribeNetwork(AppHost.getApi().login(userName,password),new NetSubscriber<List<User>>(getView(),true) {
            @Override
            public void onNext(List<User> o) {
                getView().onLoginSucceed(o.get(0));
            }
        });


    }



}
